// 权限 表
const { STRING } = require("sequelize")

const sequelize = require("../sequelize")

const rule = sequelize.define("rule", {
    rulename: {
        type: STRING,
        allowNull: false,
        unique: true,
        comment: "权限名称"
    },
    summary: {
        type: STRING,
        allowNull: false,
        comment: "权限描述"
    },
    creator: {
        type: STRING,
        comment: "创建者"
    },
    createdate: {
        type: STRING,
        comment: "创建时间"
    },
    updator: {
        type: STRING,
        comment: "最后一次更新者"
    },
    updated: {
        type: STRING,
        comment: "最后一次更新时间"
    }
}, { timestamps: false })

const role = require("./role")
const rolerule = require("./rolerule")
rule.associate = () => {
    rule.belongsToMany(role, { through: rolerule});
}

module.exports = rule